let _supplierInfo;
const USER_INFO = '_userInfo';
const SUPPLIER_INFO = '_supplierInfo';

function setUserInfo(userInfo) {
  wx.setStorageSync(USER_INFO, userInfo);
}


function getUserInfo() {
  return wx.getStorageSync(USER_INFO);
}


function setSupplierInfo(supplierInfo) {
  wx.setStorageSync(SUPPLIER_INFO, supplierInfo);
}


function getSupplierInfo() {
  return wx.getStorageSync(SUPPLIER_INFO);
}

//---------

/**
 * 这里是判断用户是否登陆过，不代表用户信息一定有，用户信息另外拉取
 */
function isLogin() {
  const app = getApp();
  return app.mpAppInfo.getToken();
}

//--------

function clearUserInfo() {
  const app = getApp();
  app.mpAppInfo.setToken('');
  setUserInfo(null);
}

function clearAll() {
  wx.clearStorageSync();
  setUserInfo(null);
}

export default {
  setUserInfo,
  getUserInfo,
  isLogin,
  clearUserInfo,
  clearAll,
  setSupplierInfo,
  getSupplierInfo

}